I am running into the following error while writing the value into a file. Can you please help me figure out what is the issue here and how to fix it?
row = 649
with open(r'\\loc\dev\Build_ver\build_ver.txt','r+') as f:
f.write(row)
print row
Error:
Traceback (most recent call last):
File "latest_rev.py", line 6, in <module>
f.write(row)
TypeError: expected a character buffer object
假设您只想将字符串'649'
写入文件,将row
更改为'649'
或发出f.write(str(row))
。
你可以做 timgeb 所做的或者你可以做的
row = str(649)
I had the same error, in my code:
s.translate(table)
The s
obj was string
. The issue was s.translate
was expecting a unicode string. So, the fix was to use:
unicode(s).translate(table)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.