Συντονιστής: konnn
python -c 'print("Hello!")'
clepto έγραψε:βασικά θέλω να χρησιμοποιήσω την python για να ανοίγω αρχεία και να γράφω-σβήνω μέσα λέξεις διότι με το bash δεν γίνεται σωστά...
#!/usr/bin/python
import sys
print("Arguments: %s" % (", ".join(sys.argv)))
def main():
defdict = {
"myfunction": myfunction(),
"myfunction2": myfunction2(),
}
print("List of supported functions: %s" % (", ".join(defdict.keys())))
if sys.argv[1] in defdict.keys():
defdict[sys.argv[1]].run()
class myfunction():
def run(self):
print("You have called myfunction")
class myfunction2():
def run(self):
try:
print("You have called myfunction2 with argument: %s" % (sys.argv[2]))
except:
print("You have called myfunction2 with no arguments")
if __name__ == "__main__":
main()
python test.py myfunction2 xyz
#!/bin/bash
name = hello
python -c 'tes.py chris'
έγραψε:#!/bin/python3
def chris():
print("Chris")
./tes.sh: line 3: name: command not found
File "<string>", line 1
tes.py chris
^
SyntaxError: invalid syntax