SORU
21 EKİM 2010, PERŞEMBE


Python: komut satırından fonksiyonu Çalıştır

Dosyama aşağıdaki kodu var:

def hello():
    return 'Hi :)'

Nasıl komut satırından çalıştırmak istiyorsunuz?

CEVAP
21 EKİM 2010, PERŞEMBE


-c ile(komut)bağımsız değişken (dosya foo.py adlı varsayarak):

$ python -c 'import foo; print foo.hello()'

Eğer ad kirliliği umurunda bile alternatif olarak,:

$ python -c 'from foo import *; print hello()'

Ve orta yere:

$ python -c 'from foo import hello; print hello()'

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • njhaley

    njhaley

    24 NİSAN 2006
  • ŠĩŗĜŕôŵåɭȍҭҭ

    ŠĩŗĜŕô

    29 Kasım 2009
  • SuicideSheeep

    SuicideSheee

    8 Ocak 2012