摘要: python下的目录操作: import os os.getcwd() #获取当前路劲 os.chdir(r’路径’) #进入某个目录下 f = open (‘test.txt’,’w’,encoding=’utf8’) #创建文件 os.makedirs(r’path\new_folder’) # 阅读全文
posted @ 2018-08-26 21:49 月半月半儿瓜 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1.文件处理(i/o处理) 在python2里用file,在python3里用open w没有创建/有就覆盖 r 阅读 a 追加 创建文件 f = file(‘myfile.txt’,’w’) f = write(“hello world!”) f.close 遍历文件内容 a = file(‘us 阅读全文
posted @ 2018-08-19 16:53 月半月半儿瓜 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 声明字符集: #一般2.x版本使用 # -*- coding:utf-8 -*- 赋值: Name = input("Name:")Age = int(input("Age:"))print(type(Age),type(str(Age))) # 格式化转换 Job = input("job:")S 阅读全文
posted @ 2018-07-16 10:18 月半月半儿瓜 阅读(161) 评论(0) 推荐(0) 编辑