首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    php入门之字符串的操作

    addcslashes — 以 C 语言风格使用反斜线转义字符串中的字符 addslashes — 使用反斜线引用字符串 bin2hex — 函数把ASCII字符的字符串转换为十六进制值 chop — rtrim 的别名 chr — 返回指定的字符 chunk_split — 将字符串分割成小块 convert_cyr_string — 将字符由一种 Cyrillic 字符转换成另一种 convert_uudecode — 解码一个 uuencode 编码的字符串 convert_uuencode — 使用 uuencode 编码一个字符串 count_chars — 返回字符串所用字符的信息 crc32 — 计算一个字符串的 crc32 多项式 crypt — 单向字符串散列 echo — 输出一个或多个字符串 explode — 使用一个字符串分割另一个字符串 fprintf — 将格式化后的字符串写入到流 get_html_translation_table — 返回使用 htmlspecialchars 和 htmlentities 后的转换表 hebrev — 将逻辑顺序希伯来文(logical-Hebrew)转换为视觉顺序希伯来文(visual-Hebrew) hebrevc — 将逻辑顺序希伯来文(logical-Hebrew)转换为视觉顺序希伯来文(visual-Hebrew),并且转换换行符 hex2bin — 转换十六进制字符串为二进制字符串 html_entity_decode — Convert all HTML entities to their applicable characters htmlentities — Convert all applicable characters to HTML entities htmlspecialchars_decode — 将特殊的 HTML 实体转换回普通字符 htmlspecialchars — Convert special characters to HTML entities implode — 将一个一维数组的值转化为字符串 join — 别名 implode lcfirst — 使一个字符串的第一个字符小写 levenshtein — 计算两个字符串之间的编辑距离 localeconv — Get numeric formatting information ltrim — 删除字符串开头的空白字符(或其他字符) md5_file — 计算指定文件的 MD5 散列值 md5 — 计算字符串的 MD5 散列值 metaphone — Calculate the metaphone key of a string money_format — Formats a number as a currency string nl_langinfo — Query language and locale information nl2br — 在字符串所有新行之前插入 HTML 换行标记 number_format — 以千位分隔符方式格式化一个数字 ord — 返回字符的 ASCII 码值 parse_str — 将字符串解析成多个变量 print — 输出字符串 printf — 输出格式化字符串 quoted_printable_decode — 将 quoted-printable 字符串转换为 8-bit 字符串 quoted_printable_encode — 将 8-bit 字符串转换成 quoted-printable 字符串 quotemeta — 转义元字符集 rtrim — 删除字符串末端的空白字符(或者其他字符) setlocale — 设置地区信息 sha1_file — 计算文件的 sha1 散列值 sha1 — 计算字符串的 sha1 散列值 similar_text — 计算两个字符串的相似度 soundex — Calculate the soundex key of a string sprintf — Return a formatted string sscanf — 根据指定格式解析输入的字符 str_getcsv — 解析 CSV 字符串为一个数组 str_ireplace — str_replace 的忽略大小写版本 str_pad — 使用另一个字符串填充字符串为指定长度 str_repeat — 重复一个字符串 str_replace — 子字符串替换 str_rot13 — 对字符串执行 ROT13 转换 str_shuffle — 随机打乱一个字符串 str_split —

    02

    python元组,文件的操作

    新手刚刚开始学习python,如有写错或者写的不好的地方,请大家多多指导! python元组相加 a = (1,2) b = (3,4) a + b 元组运用乘法 (1,2) * 4  #在这里边,元组不会被当成数字来计算,而是输出4次 给字母类型的元组拍 t = ('bb,','dd','aa','cc') tm = list(t) tm.sort()    #然后输出tm t = tuple(tm) 用for的方式运算 t = (1,2,3,4,5) l = [x + 20 for x in t] 替换元组 t = (1,[2,3],4) t[1][0] = 'spa'   #t元组中第二个数值之后紧挨着的数值 python文件操作 常见的文件运算 output = open(r'd:\a.py', 'w')   创建输出文件(w是指写入) input = open('date', 'r')        创建输入文件(r是指读写) input = open('date')             与上一行想同(r是默认值) input.read()                     把整个文件读取进单一字符串 input.read(N)                    读取之后的N个字节,到一个字符串 input.readline()                 逐行读取,第一次读取第一行,第二次读取下一行 alist = input.readlines()        读取整个文件到字符串列表 output.write(as)                 写入字节字符串到文件 output.writelines(alist)         把列表内所有字符串写入文件 output.close()                   手动关闭(当文件收集完成是会替你关闭文件) output.flush()                   把输出缓冲区刷到硬盘中,但不关闭文件 anyFile.seek(N)                  修改文件位置到偏移量N处以便进行下一个操作 for line in open('data'): use line  文件迭代器一行一行的读取 open('f.txt', encoding='latin-1')   python3.0unicode文本文件(str字符串) open('f.bin', 'rb')                 python3.0二进制byte文件(bytes字符串) 实例应用 myfile = open('myfile.txt', 'w')     #创建一个myfile.txt文件,并打开进行写入 myfile.write('hello,world\n')         myfile.write('good bye'\n)           #\n表示转行 myfile.close()               #关闭文件 然后打开本地目录,看看文件内容是否一样 读取文件 myfile = open('myfile.txt')     #打开文件,默认是只读 myfile.readline()              #读取第一行 myfile.readline()              #读取下一行 把整个文件读取进单一字符串 open('myfile.txt').read()   #把所以文件一次性读取完,\n之后的表示下一行 使用打印的方式来读取 print(open('myfile.txt').read())    #这样处理的结果比较清晰,隔行分开 用for的方式来逐行读取文件 for line in open('myfile.txt'):     print(line,end='') 以二进制的方法打开文件 data = open('myfile.txt', 'rb').read()  #这样的话效果不太明显,可以创建文本写入数字开看看 data[4:8] data[0] bin(data[0])    #二进制的方式显示一个文件 文件存储 x, y, z = 43, 44, 45 s = 'spam' d = {'a': 1,'b': 2} l = [1,2,3] f = open('data.txt', 'w') f.write(s + '\n')    #直接将s插入然后转行 f.write('%s,%s,%s\n' % (x,y,z)) f.write(str(l) + '$' str(d) + '\n')    #str输出l + str输出的d 然后读取看下结果 a = open('data.txt').read() print(a) 去掉多余的行 f = open('data

    01
    领券