我想让 PHP 中预定义多边形之外的任何东西都透明。比方说,你有你的头部形状,那么图像的任何其他部分都应该被装箱。非常感谢!为了让自己清楚,这是我一直在研究的一些代码:
$dat = dirname(__FILE__)."/foto_".time().".png";
$img = imagecreatefrompng("foto.png");
$points = array(93,36,147,1,255,-5,294,37,332,114,327,189,315,249,303,291,290,327,260,360,205,404,165,407,131,376,86,325,62,236,61,155,66,96,77,57,87,45);
$schwarz = ImageColorAllocate ($img, 0, 0, 0);
imagefilledpolygon($img, $points, count($points)/2, $schwarz);
imagepng($img, $dat);
Run Code Online (Sandbox Code Playgroud)
我正在尝试测试数据帧(el)中的一列(姓氏)是否是另一列(名称)的子字符串。我尝试过以下方法,但 python 不喜欢它
el.name.str.contains(el.surname)
Run Code Online (Sandbox Code Playgroud)
我可以看到很多有关如何搜索文字子字符串的示例,但看不到子字符串是列的情况。快被这个搞疯了,求救!
戴夫
说我有数据
data = 'A|B|2|D|0.3|5|kg|1.69|m'
Run Code Online (Sandbox Code Playgroud)
我想使用split('|')将其转换为列表,但我得到列表,其中所有值都转换为字符串.我没有在SE上看到任何类似的问题.
我怎样才能得到类似的东西:
data_list = ['A','B',2,'D',0.3,5,'kg',1.69,'m']
Run Code Online (Sandbox Code Playgroud)
数据类型的位置(int,str或float).
我不想要一个非常冗长的功能,但最简单和最简单的方法,lambda可能(我正在尝试但到目前为止没有成功)?,否则别的东西也很好.
有任何想法吗.
发布编辑:
我尝试以下列方式使用lambda:
da_list02 = map(lambda x: float(x) if type(float(x)) is float else str(x), da_list)
Run Code Online (Sandbox Code Playgroud)
但是,我得到了ValueError.ValueError:无法将字符串转换为float:A
不应该覆盖else部分lambda function吗?怎么了lambda function?
我浏览了s'flow和其他站点,以在Perl中使用regex进行简单的解决方案。
$str = q(//////);#
Run Code Online (Sandbox Code Playgroud)
假设我有六个斜线或七个斜线,或其他字符,例如q(aaaaa)
我希望他们能像分割['//','//'],
我试过了@my_split = split ( /\/\/,$str);但是没用
正则表达式可能吗?
出现此问题的原因是,说我拥有此域名:
$site_name = q(http://www.yahoo.com/blah1/blah2.txt);
我想使用单斜杠拆分以获取“域名”,但我做不到。我试过了
split( '/'{1,1}, $sitename);#没有工作。我期望它在一个斜杠上比两个斜杠分开。
谢谢。
我有一个类似于下面的示例数据的列表。列表中的每个条目都遵循“source/number_something/”模式。我想创建一个新列表,如下面的输出,其中条目只是“某物”。我想我可以使用 for 循环和字符串拆分,_但后面的一些文本也包括_. 这似乎可以用正则表达式完成,但我不太擅长正则表达式。非常感谢任何提示。
示例数据:
['source/108_cash_total/',
'source/108_customer/',
'source/108_daily_units_total/',
'source/108_discounts/',
'source/108_employee/',
'source/56_cash_total/',
'source/56_customer/',
'source/56_daily_units_total/',
'source/56_discounts/',
'source/56_employee/']
Run Code Online (Sandbox Code Playgroud)
输出:
['cash_total',
'customer',
'daily_units_total',
'discounts',
'employee',
'cash_total',
'customer/',
'daily_units_total',
'discounts',
'employee']
Run Code Online (Sandbox Code Playgroud) 我来自其他编程语言,最近发现了 lisp,并且感到很惊讶。通过阅读loop宏,我想生成一个包含带有条件的随机数的列表(让我们假设数字应该是偶数)。所以我想出了这个:
(defun some-test (range)
(loop repeat range
with item = (random 1000)
if (evenp item)
collect item))
Run Code Online (Sandbox Code Playgroud)
然而,这给了我相同的随机数range次数。我在这里做错了什么?显然,item仅评估一次,而不是在每次迭代中评估。
为了更好地使用 Lisp,我遇到了以下问题:
(defun countVowels (string)
(setf vowels (list 'a 0 'e 0 'i 0 'o 0 'u 0))
(loop for ch across string
when (member ch vowels)
do (incf (getf vowels ch)))
(format t "~{~a~^, ~}" vowels))
Run Code Online (Sandbox Code Playgroud)
在我看来,这是通过增加 plist 来计算每个元音的。但是,当我用例如调用该函数时
(countVowels "test")
Run Code Online (Sandbox Code Playgroud)
输出是
A, 0, E, 0, I, 0, O, 0, U, 0
Run Code Online (Sandbox Code Playgroud) 请帮助 R 中的 gsub 代码进行提取,9045并GT200
从中DT-9045-BIN1-C-A1, DT-GT200-BIN5-E-A2
出现在数据框中。
数据框有 1000 个条目
需要从每个条目中提取
即在第一个“-”和第二个“-”之间提取
我正在努力想出一个正则表达式来查找任何用方括号括起来的字符串。\n我从维基百科上抓取了一份大量文档,其中包含许多这样的段落:
\n\n"Theology translates into English from the Greek theologia (\xce\xb8\xce\xb5\xce\xbf\xce\xbb\xce\xbf\xce\xb3\xce\xaf\xce\xb1) which derived from \xce\xa4heos (\xce\x98\xce\xb5\xcf\x8c\xcf\x82), meaning "God," and -logia (-\xce\xbb\xce\xbf\xce\xb3\xce\xaf\xce\xb1),**[12]** meaning "utterances, sayings, or oracles" (a word related to logos **[\xce\xbb\xcf\x8c\xce\xb3\xce\xbf\xcf\x82][Citation needed]**".\nRun Code Online (Sandbox Code Playgroud)\n\n期望的结果是:
\n\n"Theology translates into English from the Greek theologia (\xce\xb8\xce\xb5\xce\xbf\xce\xbb\xce\xbf\xce\xb3\xce\xaf\xce\xb1) which derived from \xce\xa4heos (\xce\x98\xce\xb5\xcf\x8c\xcf\x82), meaning "God," and -logia (-\xce\xbb\xce\xbf\xce\xb3\xce\xaf\xce\xb1), meaning "utterances, sayings, or oracles" (a word related to logos".\nRun Code Online (Sandbox Code Playgroud)\n\n如有任何建议,我们将不胜感激。\n谢谢!
\n我在python中有一个列表:
values = ['Maths\n', 'English\n', 'Hindi\n', 'Science\n', 'Physical_Edu\n', 'Accounts\n', '\n']
print("".join(values))
Run Code Online (Sandbox Code Playgroud)
我想输出应该是: -
Subjects: Maths English Hindi Science Physical_Edu Accounts
Run Code Online (Sandbox Code Playgroud)
我是Python的新手,我使用了join()方法但无法获得预期的输出.