摘要:
np.argwhere( a ) Find the indices of array elements that are non-zero, grouped by element. 返回非0的数组元组的索引,其中a是要索引数组的条件。 返回数组中所有大于1的数字的索引值。 来源:https://bl 阅读全文
摘要:
在Python中,字符串是不可变类型,即无法直接修改字符串的某一位字符。 直接修改会报错:'str' object does not support item assignment 因此改变一个字符串的元素需要新建一个新的字符串。 常见的修改方法有以下4种。 方法1:将字符串转换成列表后修改值,然后 阅读全文
摘要:
#!/usr/bin/env python -- coding: utf-8 -- if name == 'main': list = ['html', 'js', 'css', 'python'] # 方法1 print '遍历列表方法1:' for i in list: print ("序号:% 阅读全文
摘要:
今天使用python处理一个txt文件的时候,遇到几个特殊字符:\ufeff、\xa0、\u3000,记录一下处理方法 with open(file_path, mode='r') as f: s = f.read() \ufeff 字节顺序标记 去掉\ufeff,只需改一下编码就行,把UTF-8编 阅读全文