











import re
for iterating_var in sequence:
statements(s)
-(1)list(列表)
可以理解为java的数组和列表的综合体。
替换符合正则要求的字符串。
sub(pattern, repl, string, count=0, flags=0)
hellopython.py
'''
Created on Dec 12, 2018
@author: xiaobin
'''
import os
import re
#! /usr/bin/perl
# @lines=`perldoc -u -f sin`;
# foreach(@lines){
# s/\w<([^>]+)/\U$1/g;
# print;
# }
cmdPydoc = 'pydoc math.sin'
lines = os.popen(cmdPydoc, 'r', -1).readlines()
for echostr in lines :
str1 = re.sub('([.]+){3}', "num", echostr, re.S)
print(str1)
else:
print("---- over ----")
#### 1)关于os.system和os.popen
相同点:都是调用shell。
不同点:
install pydoc
sudo apt install python-dev-is-python3

此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。