Geliştirici Üye
    
Üyelik Tarihi: 03-02-2016
Yorum Sayısı: 1,077
Konu Sayısı: 12
Rep Puanı:
9
vayy bu iyi oldu deneyeyim bunları Abi sağol
Bu da kıpraşım
PHP Kod:
import androidhelper d=androidhelper.Android() d.vibrate(duration=300)
Bu da media dosyası için, dosya kısmında mp3 dosyasının yonu belirtin sonra setMediaVolume kısmında ses düzeyini ayarlayın
PHP Kod:
import androidhelper dosya="/sdcard/xxx.mp3" d=androidhelper.Android() d.setMediaVolume(12) d.mediaPlay(dosya,play=True)
Yeni Üye
Üyelik Tarihi: 11-02-2016
Yorum Sayısı: 17
Konu Sayısı: 0
Rep Puanı:
0
tesekkurler biraz ogrenince denicem
Cezalı Üye
Üyelik Tarihi: 13-08-2016
Yorum Sayısı: 14
Konu Sayısı: 0
13-08-2016, Saat: 03:48
(Son Düzenleme: 13-08-2016, Saat: 07:56, Düzenleyen: GmB.
Sebep: Sorun çözüldü
)
PHP Kod:
tip=input("cift/tek (2,1):"); altLimit=int(input("Bir alt limit girin:")); ustLimit=int(input("Bir ust limit girin:")); toplam=0; if(tip==2 | tip=="cift"): tipim = "cift"; for i in range(altLimit, ustLimit): if(i%2==0): print(i); #2'nin katlarini aldik :P toplam=toplam+i; elif(tip==1 | tip=="tek"): tipim = "tek"; for i in range(altLimit, ustLimit): if(i%3==0): print(i); #3'un katlarini aldik :P toplam=toplam+i; else: exit("Taniyamadim baba bastan al"); print (altLimit,"ile",ustLimit,"arasindaki",tipim,"sayilarin toplami:",toplam);
PHP'den python'a geçiş yapıyorum da, 5. satırdaki if sorgusunda hata var diyor...
Someone can help me?
Dipçik notu: Çalıştığım python sürümü 352
---------------03:58----------------
PHP Kod:
from time import sleep
tip=input("cift/tek (2,1):"); toplam=0; if(tip==2 or tip=="cift"): altLimit=int(input("Bir alt limit girin:")); ustLimit=int(input("Bir ust limit girin:")); tipim = "cift"; for i in range(altLimit, ustLimit): if(i%2==0): print(i); #2'nin katlarini aldik :P toplam=toplam+i; elif(tip==1 or (tip=="tek")): altLimit=int(input("Bir alt limit girin:")); ustLimit=int(input("Bir ust limit girin:")); tipim = "tek"; for i in range(altLimit, ustLimit): if(i%3==0): print(i); #3'un katlarini aldik :P toplam=toplam+i; else: print("Taniyamadim baba bastan al"); sleep(2); exit(); print (altLimit,"ile",ustLimit,"arasindaki",tipim,"sayilarin toplami:",toplam);
Bu seferde ilk condition'ı tanımıyor :SS
----03:58----
Tanımaz tabi anasını satayım gelen değer int değil ki, str  DD
PHP Kod:
from time import sleep
tip=input("cift/tek (2,1):"); toplam=0; if(tip=="2" or tip=="cift"): altLimit=int(input("Bir alt limit girin:")); ustLimit=int(input("Bir ust limit girin:")); tipim = "cift"; for i in range(altLimit, ustLimit): if(i%2==0): print(i); #2'nin katlarini aldik :P toplam=toplam+i; elif(tip=="1" or (tip=="tek")): altLimit=int(input("Bir alt limit girin:")); ustLimit=int(input("Bir ust limit girin:")); tipim = "tek"; for i in range(altLimit, ustLimit): if(i%3==0): print(i); #3'un katlarini aldik :P toplam=toplam+i; else: print("Taniyamadim baba bastan al"); sleep(2); exit(); print (altLimit,"ile",ustLimit,"arasindaki",tipim,"sayilarin toplami:",toplam);
Cezalı Üye
Üyelik Tarihi: 13-08-2016
Yorum Sayısı: 14
Konu Sayısı: 0
PHP Kod:
#!/usr/bin/env python # Description: converts curl statements to python code # # Usage: # python curl2.py 'curl "http://localhost:8080/api/v1/test" -H "Pragma: no-cache" etc' # # Inspired by http://curl.trillworks.com/
import sys import shlex
def curlToPython(command): """convert curl command to python script""" # remove quotations args = shlex.split(command) # check for method if '-X' in args: method = args[args.index('-X') + 1] else: method = 'get'
url = args[1] # TODO: convert to dict comprehension? # {args[i + 1].split(':')[0]: args[i + 1].split(':')[1].strip() for i, v in enumerate(args) if v == '-H'} # gather all the headers headers = {} for i, v in enumerate(args): if '-H' in v: myargs = args[i + 1].split(':') headers[myargs[0]] = myargs[1].strip()
pycode = []
# print code to stdout pycode.append("#!/usr/bin/env python") pycode.append("import requests")
# check for a cookie bCook = 'Cookie' in headers if bCook: cookie = headers['Cookie'] del headers['Cookie'] cook = cookie.split('=') pycode.append("""cookies = {{ '{COOKIEID}': '{COOKIE}' }}""".format(COOKIEID=cook[0], COOKIE=cook[1]))
# assumes there are headers pycode.append("headers = {") for k, v in headers.iteritems(): pycode.append(" '{k}': '{v}',".format(k=k, v=v)) pycode.append("}") pycode.append("url = '{0}'".format(url)) # if there is a cookie, then attach it to the requests call resstr = "res = requests.{method}(url, headers=headers".format( method=method) if bCook: pycode.append("{0}, cookies=cookies)".format(resstr)) else: pycode.append("{0})".format(resstr)) return pycode
def resToCurl(res): """converts a requests response to a curl command
>>> res = requests.get('http://www.example.com') >>> print resToCurl(res) curl 'http://www.example.com/' -X 'GET' ...
Source: http://stackoverflow.com/a/17936634 """ req = res.request command = "curl '{uri}' -X '{method}' -H {headers}" method = req.method uri = req.url data = req.body headers = ["{0}: {1}".format(k, v) for k, v in req.headers.items()] headerLine = " -H ".join(['"{0}"'.format(h) for h in headers]) if method == 'GET': return command.format(method=method, headers=headerLine, uri=uri) else: command += " --data-binary '{data}'" return command.format(method=method, headers=headerLine, data=data, uri=uri)
if __name__ == "__main__": if len(sys.argv) == 1: command = 'curl "http://localhost:8080/api/v1/test" -H "Pragma: no-cache" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: en-US,en;q=0.8"' else: command = sys.argv[1] code = curlToPython(command) print('\n'.join(code))
Kod:
Traceback (most recent call last):
File "C:\PyProjects\curl.py", line 90, in <module>
code = curlToPython(command)
File "C:\PyProjects\curl.py", line 50, in curlToPython
for k, v in headers.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
Fonksiyon olduğunu neden tespit edemedi ki ://
Cezalı Üye
Üyelik Tarihi: 13-08-2016
Yorum Sayısı: 14
Konu Sayısı: 0
PHP Kod:
#!/usr/bin/env python # -*- coding: utf-8 -*- TestText = "UTF-8 DENEMESİ - şçpğıaAeEcC..šŠuUzZ" # Unicode string Python 3.X. TestText2 = TestText.encode("utf8") # Make UTF-8. print(TestText2) #b'UTF-8 DENEMES\xc4\xb0 - \xc5\x9f\xc3\xa7p\xc4\x9f\xc4\xb1aAeEcC..\xc5\xa1\xc5\xa0uUzZ'
Neden utf8 çevirmesini gerçekleştirmiyor lanet :/
Cezalı Üye
Üyelik Tarihi: 13-08-2016
Yorum Sayısı: 14
Konu Sayısı: 0
13-08-2016, Saat: 07:54
(Son Düzenleme: 13-08-2016, Saat: 07:55, Düzenleyen: GmB.)
2.x ile 3.x arasında performans farkı var mı?
2.x için kaynak ve ördek daha bôl gibi geldi
Geliştirici Üye
    
Üyelik Tarihi: 03-02-2016
Yorum Sayısı: 1,077
Konu Sayısı: 12
Rep Puanı:
9
yaptığın utf8 encode doğru bence. bazen hata verebiliyor bende geçen yaptığım kodda tlf da asci hatası veriyordu pc de vermedi.
ayrıca if de iki veya daha fazla değer atayacaksan araya "or " kullanmalısın.
Cezalı Üye
Üyelik Tarihi: 13-08-2016
Yorum Sayısı: 14
Konu Sayısı: 0
(13-08-2016, Saat: 10:23)hkrgln Nickli Kullanıcıdan Alıntı: yaptığın utf8 encode doğru bence. bazen hata verebiliyor bende geçen yaptığım kodda tlf da asci hatası veriyordu pc de vermedi.
ayrıca if de iki veya daha fazla değer atayacaksan araya "or " kullanmalısın.
Geç oldu sanki
Çoktan çözdüm onları
Şimdikisi şööüyyle, multi_threading ile websitelerini ziyaret etmek istiyorum
her defasında da url adresinin sonuna array'den gelen bir eki koymak istiyorum ek olaraktan...
hatta array baba kaç taneyse o kadar yapsın bu işlemi
var mı örnek kod, rehber falan?
|