因为python跟java在数据类型转换方面语法不同,所以总是搞混,特此记录下来,方便查阅: 在python中: 字符串str转换成int: int_value = int(str_value) int转换成字符串str: str_value = str(int_value) int -> unicode: unicode(int_value) unicode -> int: int(unicode_value) str -> unicode: unicode(str_value) unicode -> str: str(unicode_value) int -> str: str(int_value) str -> int: int(str_value)
在java中: 字符串String转换成int: int_value = String.parseInt(string_value)或(int)string_value int转换成字符串String: string_value = (String)int_value 注意括号的位置! |
|
来自: LibraryPKU > 《Python》