- 论坛徽章:
- 0
|
# This is a comment
127.0.0.1 localhost
192.168.2.253 pyschools # python server
Examples
>>> gethostname('127.0.0.1')
'localhost'
>>> gethostname('192.168.2.253')
'pyschools'
>>> gethostname('192.168.2.254') # Returns 'Unknown host' if ip address is not found.
'Unknown host' - # Write a function that reads the /etc/hosts and return the hostname, given the ip address.
- def gethostname(ip_address):
- for line in open("/etc/hosts"):
- line = line.rstrip()
- if ip_address in line:
- return line.split(' ')[-1]
- break
- else:
- return "Unknown host"
复制代码
官方给出的解释是What does it mean when I failed the Private Test Cases?
Private test cases are hidden test cases created to prevent the users from hardcoding the answers to the visible test cases. If you fail the private test cases, look at the samples for some clues that you may miss. For example, there may be a missing '\n' or ' ' (space) which is not apparent between the Returned and Expected results.
费了老大劲,还是不知道哪里出错。 |
|