B*A 发帖数: 83 | 1 请教下思路
很多文章都有标题, 然后又小标题, 小标题下面有几段话具体论述小标题。 有没有
办法classify 一段话是本身是小标题还是正文? 各位高手能提供一下思路吗?
例如以下文字是我随便从网上copy的。 其中“Required arguments", ”Keyword
arguments“ 就是小标题, 其他部分是正文。
谢谢了
================================================
Required arguments
Required arguments are the arguments passed to a function in correct
positional order. Here, the number of arguments in the function call should
match exactly with the function definition.
To call the function printme(), you definitely need to pass one argument,
otherwise it gives a syntax error as follows −
Live Demo
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme()
When the above code is executed, it produces the following result −
Traceback (most recent call last):
File "test.py", line 11, in
printme();
TypeError: printme() takes exactly 1 argument (0 given)
Keyword arguments
Keyword arguments are related to the function calls. When you use keyword
arguments in a function call, the caller identifies the arguments by the
parameter name.
This allows you to skip arguments or place them out of order because the
Python interpreter is able to use the keywords provided to match the values
with parameters. You can also make keyword calls to the printme() function
in the following ways − |
|