代码显示为:
file=open('cake.txt','w')
出现以下内容:
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
open('cake.txt','w')
TypeError: an integer is required (got type str)
此语法在3.6版本上可以完美运行,现在我升级到了3.7,但现在还没有。这是怎么回事顺便说一下,“ cake.txt”文件不存在。
python文档也无济于事。
答案 0 :(得分:1)
如果是的话,那就是
FXX_03_Data_8To11_byAgeRange <- structure(list(F20_AgeRange = c("26 - 30", "31 - 35", "36 - 40",
"41 - 45", "46 - 50", "51 - 55", "56 - 60"),
n_Count = c(5L,13L, 59L, 110L, 52L, 14L, 2L),
Prozent = c(2, 5.1, 23.1, 43.1,20.4, 5.5, 0.8)),
.Names = c("F20_AgeRange", "n_Count", "Prozent"),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -7L))
FXX_03_Data_byAgeRange <- structure(list(F20_AgeRange = c("18 – 25", "26 - 30", "31 - 35",
"36 - 40", "41 - 45", "46 - 50", "51 - 55", "56 - 60"),
n_Count = c(3L,12L, 25L, 65L, 118L, 58L, 19L, 4L),
Prozent = c(1, 3.9, 8.2, 21.4, 38.8, 19.1, 6.2, 1.3)),
.Names = c("F20_AgeRange", "n_Count", "Prozent"),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -8L))
ggplot() +
geom_bar(data = FXX_03_Data_8To11_byAgeRange, aes(x = F20_AgeRange, y = Prozent, fill = "Parents 8 to 11"), stat = "identity", width = 0.4, position = position_nudge(x = 0.25)) +
geom_bar(data = FXX_03_Data_byAgeRange, aes(x = F20_AgeRange, y = Prozent, fill = "Parents accumulated"), stat = "identity", width = 0.4, position = position_nudge(x = - 0.25))
您已将open
替换为os.open
。 from os import *
将是您尝试传递flags
的{{1}},但实际上可能不是您想要的功能。
open
函数和方法有很多。最好注意通配符的导入。
(例如,如果是在交互式会话中,则还可以输入int
,这应该使您对正在处理的mode
有个好主意。
社区Wiki答案反映了评论...随时可以改进。